package org.aiforum.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 用户类
 * @author VIC
 *
 */
@NamedQueries({@NamedQuery(name="queryByAccount",query="from User u where u.account = :account")})
@Entity// 标识ai_user类是一个pojo类
@Table(name="ai_user")// 标识配置映射ai_urser类对应的表
public class User {
	
	// strategy标识主键生成策略,GenerationType.SEQUENCE表示使用序列
	// generator表示使用哪个序列生成器
	// sequenceName表示定义数据库中的序列名称
	// name表示序列生成器名称
	// initialValue设置序列初始值
	// allocationSize设置每次增长值
	@Id// 标识userid属性为主键
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="user_sequence")// 标识主键生成值
	@SequenceGenerator(sequenceName="SEQ_USER",name="user_sequence",initialValue=11,allocationSize=1)// 标识定义序列生成器
	private int userId;// ID
	
	// @Column表示配置属性对应的字段名称
	@Column(name="account")
	private String account;// 账号
	@Column(name="password")
	private String password;// 密码
	@Column(name="email")
	private String email;// 邮箱
	@Column(name="state")
	private int state;// 用户状态
	@Column(name="createDate")
	private Date createDate;//用户创建时间
	
	public User(){}
	
	public User(int userId, String account, String password, String email, int state, Date createDate) {
		this.userId = userId;
		this.account = account;
		this.password = password;
		this.email = email;
		this.state = state;
		this.createDate = createDate;
	}



	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Override
	public String toString() {
		return "User [userId=" + userId + ", account=" + account + ", password=" + password + ", email=" + email
				+ ", state=" + state + ", createDate=" + createDate + "]";
	}

	
    
}
